﻿using PECommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BattleServer
{
    /// <summary>
    /// 基础组件组成的逻辑单位
    /// </summary>
    public abstract class SLogicBase : ILogic
    {
        protected readonly List<IAwake> mAwakeList = new();
        protected readonly List<IUpdate> mUpdateList = new();
        protected readonly List<IDestory> mDestroyList = new();
        public void Awake()
        {
            for (int i = 0; i < mAwakeList.Count; i++)
            {
                mAwakeList[i].Awake();
            }
        }

        public void Update()
        {
            for (int i = 0; i < mUpdateList.Count; i++)
            {
                mUpdateList[i].Update();
            }
        }

        public void Destory()
        {
            for (int i = 0; i < mDestroyList.Count; i++)
            {
                mDestroyList[i].Destory();
            }
            mAwakeList.Clear();
            mUpdateList.Clear();
            mDestroyList.Clear();
        }
    }
}
